//  Ids.js
const mongoose = require("mongoose");
const transDatePlugin = require("../../plugins/transDatePlugin");
const Schema = mongoose.Schema;

const IdsSchema = new Schema(
	{
		type: {
			type: String,
			required: true,
			unique: true, //字段唯一性
		},
		id: {
			type: Number,
			required: true, //是否必需
			default: 1,
		},
		create_time: {
			type: String,
			required: true,
			default: Date.now,
		},
		update_time: {
			type: String,
		},
	},
	{
		versionKey: false,
		timestamps: { createdAt: "create_time", updatedAt: "update_time" },
	}
);

IdsSchema.plugin(transDatePlugin, { paths: ["update_time"] });
module.exports = IDs = mongoose.model(
	"ids",
	IdsSchema,
	`${process.env.PREFIX}_ids`
);
